package com.csd.action.manager;

import java.util.ArrayList;
import java.util.List;

import com.csd.helper.ActionResult;
import com.csd.helper.IConstant;
import com.csd.pojo.ChangeRecord;
import com.csd.pojo.Message;
import com.csd.service.IChangeRecordService;
import com.csd.vo.ChangeRecordVO;
/**
 * 管理员未处理的变更
 * @author 三木
 *	<br>创建于2009-12-17
 */
public class ChangeRecordUnhandleListAction {
	
	private Integer numInPage;

	private Integer currPage;
	
	private Integer totalPage;

	public Integer getNumInPage() {
		return numInPage;
	}

	public void setNumInPage(Integer numInPage) {
		this.numInPage = numInPage;
	}

	public Integer getCurrPage() {
		return currPage;
	}

	public void setCurrPage(Integer currPage) {
		this.currPage = currPage;
	}

	public Integer getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(Integer totalPage) {
		this.totalPage = totalPage;
	}

	private List<ChangeRecordVO> changeRecordVOList;
	
	private IChangeRecordService changeRecordService;

	public List<ChangeRecordVO> getChangeRecordVOList() {
		return changeRecordVOList;
	}

	public void setChangeRecordVOList(List<ChangeRecordVO> changeRecordVOList) {
		this.changeRecordVOList = changeRecordVOList;
	}

	public IChangeRecordService getChangeRecordService() {
		return changeRecordService;
	}

	public void setChangeRecordService(IChangeRecordService changeRecordService) {
		this.changeRecordService = changeRecordService;
	}
	
	public String execute() throws Exception{
		String text = ActionResult.fail;
		
		//changeRecordVOList = changeRecordService.listUnhandleCROfManager();
		//获得管理员未处理的变更
		List<ChangeRecordVO> old = changeRecordService.listUnhandleCROfManager();
		
		if( this.currPage == null  || this.currPage <= 0 )
			this.currPage = 1;
		
		if( this.numInPage == null || this.numInPage <= 0)
			this.numInPage = IConstant.numInPage;
		
		if(changeRecordVOList == null)
		{
			changeRecordVOList = new ArrayList<ChangeRecordVO>();
		}
		
		if(old == null)
		{
			old = new ArrayList<ChangeRecordVO>();
		}
		
		changeRecordVOList.clear();
		
		for(int i = (this.currPage-1)*this.numInPage; 
				i < this.currPage*this.numInPage && i < old.size(); 
				i++)
		{
			changeRecordVOList.add( old.get(i) );
		}
		

		this.totalPage = old.size() / this.numInPage;
		
		if(old.size() % this.numInPage != 0)
			this.totalPage++;
		text = ActionResult.success;
		return text;
	}
}
